//用于测试的api
import request from '@/utils/httpRequest/request'

const api = {
    getNews: '/api/article/news',
    getKnowledge: '/api/article/knowledge',
    getRumors: '/api/article/rumors',
    read: '/api/article/read',
    delete: '/api/article/delete',
    getAnnouncements: "/api/article/announcement",
    saveArticle : '/api/article/create',
    getpostlist: '/api/post/list',
    getinstitute: '/api/article/official',
    getpost: '/api/post/one',
    comment: '/api/comment/one',
    reply: '/api/comment/replyToComment',
    show: '/api/comment/ofAnArticle',
    commentpost: '/api/post/replyToPost',
    releasepost: '/api/post/one',
    replytoreply: '/api/post/replyToReply'

}

export const article = {
    getNews: function(page, size, keyword) {
        return request({
            url: api.getNews,
            method: 'get',
            params: {
                page: page,
                size: size,
                keyword: keyword
            }
        })
    },
    getRumors: function(page, size, keyword) {
        return request({
            url: api.getRumors,
            method: 'get',
            params: {
                page: page,
                size: size,
                keyword: keyword
            }
        })
    },
    delete: function(id) {
        return request({
            url: api.delete,
            method: 'delete',
            params: {
                id: id
            }
        })
    },
    getKnowledge: function(page, size, keyword) {
        return request({
            url: api.getKnowledge,
            method: 'get',
            params: {
                page: page,
                size: size,
                keyword: keyword,
            }
        })
    },
    getAnnouncements: function(page, size, keyword) {
        return request({
            url: api.getAnnouncements,
            method: 'get',
            params: {
                page: page,
                size: size,
                keyword: keyword,
            }
        })
    },
    read: function(id) {
        return request({
            url: api.read,
            method: 'get',
            params: {
                id: id,
            }
        });
    },
    saveedit: function (article){
        return request({
            url: api.saveArticle,
            method : 'post',
            data:{
                id: article.id,
                title: article.title,
                thumbnail:article.thumbnail,
                content:article.content,
                type:article.type,
                runmorExtObj:article.extObj,
                source:article.source
            }
        })
    },
    getpostlist: function (){
        return request({
            url: api.getpostlist,
            method: 'get',
            param:{

            }
        })
    },
    getinstitute: function (){
        return request({
            url: api.getinstitute,
            method: 'get',
            param:{

            }
        })
    },
    getpost: function (id){
        return request({
            url: api.getpost,
            method: 'get',
            params:{
                id:id
            }
        })
    },
    comment: function(content,userId,passageId) {
        return request({
            url: api.comment,
            method: 'post',
            data: {
                content:content,
                userId:userId,
                passageId:passageId
            }
        })
    },
    reply: function(content, userId, commentId) {
        return request({
            url: api.reply,
            method: 'post',
            data: {
                content:content,
                userId:userId,
                commentId:commentId
            }
        })
    },
    show: function(id) {
        return request({
            url: api.show,
            method: 'get',
            params: {
                id: id,
            }
        })
    },
    commentpost: function (content,userid,askid){
        return request({
            url:api.commentpost,
            method: 'post',
            data:{
                content:content,
                userId:userid,
                askId:askid
            }
        })
    },
    releasepost: function (title,content,userid){
        return request({
            url:api.releasepost,
            method:'post',
            data:{
                title:title,
                content:content,
                userId:userid
            }
        })
    },
    replytoreply: function (content,userid,replyid){
        return request({
            url:api.replytoreply,
            method:'post',
            data:{
                content:content,
                userId:userid,
                replyId:replyid
            }
        })
    }
}